什麼是DockerFile呢?在前面幾天大概對Docker有個基本的運作概念,可以把他想像把Docker一長串指令整理成一個檔,方便修改及管理,重點是方便閱讀
我們來了解基本DockerFile如何使用
先創建一個名為DockerFile的檔案
FROM "Image Name":"Tag"
ENV "Environment Value Name" = "Environment Value"
ARG "MY_ARG"="Default Value"
RUN "Command"
COPY "Local Path" "Container Path"
ADD "Local Path" "Container Path"
WORKDIR "Container Path"
CMD ["Container Start Run Command"]
ENTRYPOINT ["Container Start Run Command"]
docker pull "Image Name":"Tag"
docker run -e Environment Value Name=Environment Value
docker build --build-arg MY_ARG=Default Value -t Image Name .
docker run -it "Image Name" /bin/bash -c "Command"
docker cp "Local Path" "Container Name":"Container Path"
docker run -w "Container Path" "Image Name"
docker run your_image sh -c "CMD or ENTRYPOINT Command"
DockerFile是不是一個很重要的概念啊,我們不用打一長串的指令,而且他就是個文件,爾且可讀性很高